package diploma.kisel.modelas.service;

import java.util.List;

import diploma.kisel.modelas.domain.Role;
import diploma.kisel.modelas.repository.RoleRepositoryImpl;
import diploma.kisel.modelas.repository.api.RoleRepository;
import diploma.kisel.modelas.service.api.RoleService;

public class RoleServiceImpl implements RoleService {

	private RoleRepository roleRepository = new RoleRepositoryImpl();

	@Override
	public List<Role> findAll() {
		return roleRepository.findAll();
	}

	@Override
	public Role save(Role role) {
		return roleRepository.save(role);
	}

	@Override
	public Role update(Role role) {
		return roleRepository.update(role);
	}

	@Override
	public void remove(Role role) {
		if (role.getId() != null)
			roleRepository.remove(role);

	}

	@Override
	public void remove(String id) {
		Role role = roleRepository.findById(id);
		roleRepository.remove(role);

	}

	@Override
	public Role findById(String id) {
		return roleRepository.findById(id);
	}

}
